<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Start a new template</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.ps-begin-pattern.html">« ps_begin_pattern</a></li>
      <li style="float: right;"><a href="function.ps-circle.html">ps_circle »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.ps.html">PS 函数</a></li>
    <li>Start a new template</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.ps-begin-template" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ps_begin_template</h1>
   <p class="verinfo">(PECL ps &gt;= 1.2.0)</p><p class="refpurpose"><span class="refname">ps_begin_template</span> &mdash; <span class="dc-title">Start a new template</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.ps-begin-template-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>ps_begin_template</strong></span>(<span class="methodparam"><span class="type">resource</span> <code class="parameter">$psdoc</code></span>, <span class="methodparam"><span class="type">float</span> <code class="parameter">$width</code></span>, <span class="methodparam"><span class="type">float</span> <code class="parameter">$height</code></span>): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   Starts a new template. A template is called a form in the postscript
   language. It is created similar to a pattern but used like an image.
   Templates are often used for drawings which are placed several times
   through out the document, e.g. like a company logo. All drawing functions
   may be used within a template. The template will not be drawn until
   it is placed by <span class="function"><a href="function.ps-place-image.html" class="function">ps_place_image()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.ps-begin-template-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">psdoc</code></dt>

     <dd>

      <p class="para">
       Resource identifier of the postscript file
       as returned by <span class="function"><a href="function.ps-new.html" class="function">ps_new()</a></span>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">width</code></dt>

     <dd>

      <p class="para">
       The width of the template in pixel.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">height</code></dt>

     <dd>

      <p class="para">
       The height of the template in pixel.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.ps-begin-template-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code>true</code></strong>， 或者在失败时返回 <strong><code>false</code></strong>。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.ps-begin-template-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3179">
    <p><strong>示例 #1 Creating and using a template</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$ps&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ps_new</span><span style="color: #007700">();<br /><br />if&nbsp;(!</span><span style="color: #0000BB">ps_open_file</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"template.ps"</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;print&nbsp;</span><span style="color: #DD0000">"Cannot&nbsp;open&nbsp;PostScript&nbsp;file\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;exit;<br />}<br /><br /></span><span style="color: #0000BB">ps_set_parameter</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"warning"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"true"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_set_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Creator"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"template.php"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_set_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Author"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Uwe&nbsp;Steinmann"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_set_info</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Title"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"Template&nbsp;example"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$pstemplate&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">ps_begin_template</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30.0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_moveto</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_lineto</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_moveto</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_lineto</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_stroke</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_end_template</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">ps_begin_page</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">596</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">842</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_place_image</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pstemplate</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">20.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">20.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1.0</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_place_image</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pstemplate</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">50.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0.5</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_place_image</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pstemplate</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">70.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">70.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0.6</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_place_image</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pstemplate</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">30.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">50.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1.3</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_end_page</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">ps_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">ps_delete</span><span style="color: #007700">(</span><span style="color: #0000BB">$ps</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.ps-begin-template-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.ps-end-template.html" class="function" rel="rdfs-seeAlso">ps_end_template()</a> - End a template</span></li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>